Skip to content

Add example showing that uninitialized var doesn't override a same-name function#44537

Merged
Josh-Cena merged 3 commits into
mdn:mainfrom
Anusha-Pwr:add-var-function-redeclaration-example
Jul 12, 2026
Merged

Add example showing that uninitialized var doesn't override a same-name function#44537
Josh-Cena merged 3 commits into
mdn:mainfrom
Anusha-Pwr:add-var-function-redeclaration-example

Conversation

@Anusha-Pwr

Copy link
Copy Markdown
Contributor

Description

Adds a clarifying example to the var redeclarations section showing that a var declaration without an initializer does not overwrite the value of a same-name function declaration.

Motivation

The page already explains that duplicate var declarations without initializers do not overwrite an existing value, and that a var initializer overrides a same-name function declaration. This example directly shows the related case of a var declaration without an initializer alongside a same-name function declaration, making that behavior clearer for readers.

Additional details

None

Related issues and pull requests

None

@Anusha-Pwr
Anusha-Pwr requested a review from a team as a code owner June 21, 2026 18:59
@Anusha-Pwr
Anusha-Pwr requested review from sideshowbarker and removed request for a team June 21, 2026 18:59
@github-actions github-actions Bot added Content:JS JavaScript docs size/s [PR only] 6-50 LoC changed labels Jun 21, 2026
@github-actions

github-actions Bot commented Jun 21, 2026

Copy link
Copy Markdown
Contributor

Preview URLs (1 page)

Flaws (1)

Found an unexpected or unresolvable flaw? Please report it here.

URL: /en-US/docs/Web/JavaScript/Reference/Statements/var
Title: var
Flaw count: 1

  • macros:
    • Macro jsxref produces link /en-US/docs/Web/JavaScript/Reference/delete which is a redirect

(comment last updated: 2026-07-12 19:52:22)

@Anusha-Pwr

Copy link
Copy Markdown
Contributor Author

Hi! Just checking in on this PR when someone has time.
The checks had passed, and I also noticed that the preview reports one flaw for an existing {{jsxref("delete")}} link on this page. It seems unrelated to my change, but I’d be happy to update it in this PR too if maintainers prefer.

Thanks!

@Josh-Cena

Copy link
Copy Markdown
Member

Thanks, but I think, as you already pointed out, this fact can be reasonably deduced from the previous two points and does not need to be explained yet again. There are way too many pairwise interactions between these declarations and it's not worthwhile demonstrating every kind.

@Josh-Cena Josh-Cena closed this Jul 12, 2026
@Josh-Cena Josh-Cena reopened this Jul 12, 2026
@Josh-Cena

Copy link
Copy Markdown
Member

Actually on second thought, I think this is worth it.

@Josh-Cena Josh-Cena left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice addition, thank you!

@Josh-Cena
Josh-Cena merged commit ae58f6b into mdn:main Jul 12, 2026
8 of 9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Content:JS JavaScript docs size/s [PR only] 6-50 LoC changed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants